#Twisted Shootout
#Copyright (C) 2007 Han Dao
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

#You can contact the author at wikipediankiba@gmail.com
import pygame
import data
import map
class MapData:
	def __init__(self,engine,name):
		self.engine = engine
		self.data = data.read
		self.data.name = name
		self.engine.obj = self.data.mapload()
		self.coordinate()
		self.datacomputes()
	def coordinate(self):
		rows = 0
		columns = 0
		while True:
			a = columns * 80
			b = rows * 60
			self.engine.c.append([a,b])
			columns = columns + 1
			if columns == 30:
				rows = rows + 1
				columns = 0
			if rows == 30:
				return
	def datacomputes(self):
		n = 0
		for v in self.engine.obj[0]:
			if v == 2:
				image = data.read.load('wall1',True)
			elif v == 3:
				image = data.read.load('block',True)
			elif v == 4:
				image = data.read.load('block2',True)
			elif v == 5:
				image = data.read.load('tunnel',True)
			elif v == 7:
				image = data.read.load("win",True)
			elif v == 0:
				image = data.read.load('blank',True)
			obj = map.Map(image)
			if v == 3:
				obj.property = True
			elif v == 4:
				obj.property = True
			elif v == 7:
				obj.win = True
			obj.sets(self.engine.c[n][0],self.engine.c[n][1])
			self.engine.mapobj.append(obj)
			self.engine.sprites.add(obj)
			n = n + 1
		self.engine.items.datacompute()